cmake_minimum_required(VERSION 3.10)
project(resource_optical_clip_detector)

## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)
set(CMAKE_CXX_FLAGS_DEBUG "-fPIC -O0 -g -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "-fPIC -O2 -Wall")

set(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")

find_package(CUDA REQUIRED)

###########
find_package(OpenCV REQUIRED)
find_package(Boost REQUIRED COMPONENTS
    system
    filesystem
    serialization)


set(TENSORRT_DIR "/home/xjl/tensorrt/TensorRT-8.6.1.6.Linux.x86_64-gnu.cuda-11.8/TensorRT-8.6.1.6")
include_directories(
        ${CMAKE_BINARY_DIR}/include
        ${OpenCV_INCLUDE_DIRS}
        include
        ${PROJECT_SOURCE_DIR}/include
        ${TENSORRT_DIR}/include
        /usr/local/cuda/include
)
link_directories(
        ${PROJECT_BINARY_DIR}/lib
        /usr/local/libs
        /usr/lib
        /usr/local/cuda/lib64 
        ${TENSORRT_DIR}/lib
)






    
  ##########
  # OUTPUT #
  ##########
  add_library(${PROJECT_NAME} SHARED
    src/yolov3_clip_detector.cpp
  )

  target_link_libraries(${PROJECT_NAME}
        cudart
        boost_system
        boost_serialization
        boost_iostreams
        ${TENSORRT_LIBRARY}
        ${OpenCV_LIBRARIES}
        ${Boost_LIBRARIES}
        )



message("The engine compile platform include: GPU.")

 

  target_link_libraries(${PROJECT_NAME}
          ${OpenCV_LIBRARIES}
          )
  
  add_executable(test_${PROJECT_NAME}
    test/test.cpp
  )

  set(TENSORRT_LIBS nvinfer nvinfer_plugin nvparsers nvonnxparser)

  target_link_libraries(test_${PROJECT_NAME}
    ${OpenCV_LIBRARIES}
    ${PROJECT_NAME}
    boost_system
    boost_serialization
    boost_iostreams
    ${OpenCV_LIBRARIES}
    ${TENSORRT_LIBS}
  )



  

